package o;

import com.huawei.appgallery.foundation.ui.css.CSSStyleSheet;
import com.huawei.appgallery.foundation.ui.framework.cardframe.bean.BaseCardBean;
import com.huawei.appgallery.foundation.ui.framework.cardframe.bean.BaseDetailResponse.Layout;
import com.huawei.appgallery.foundation.ui.framework.cardframe.bean.BaseDetailResponse.LayoutData;
import com.huawei.appgallery.foundation.ui.framework.cardkit.bean.CardBean;
import com.huawei.appgallery.serverreqkit.api.bean.ResponseBean;
import com.huawei.gamebox.framework.cardkit.bean.WiseJointDetailResponse;
import java.util.List;
import java.util.ListIterator;
import org.json.JSONObject;

public final class bet {
    public static void ˏ(cia o_cia, BaseRequest o_cvu, ResponseBean responseBean) {
        eyi o_eyi = (eyi) o_cvu;
        WiseJointDetailResponse wiseJointDetailResponse = (WiseJointDetailResponse) responseBean;
        List ʻॱ = wiseJointDetailResponse.ʻॱ();
        List ᐝॱ = wiseJointDetailResponse.ᐝॱ();
        JSONObject ॱˎ = wiseJointDetailResponse.ॱˎ();
        if (ॱˎ != null) {
            o_cia.csSheet = CSSStyleSheet.parse(ॱˎ);
        }
        ॱ(o_cia, ʻॱ);
        int ˊ = ˊ(o_cia, ᐝॱ);
        if (wiseJointDetailResponse.ॱ() == 0) {
            o_cia.ˊ(false);
        } else {
            o_cia.ˊ(true);
        }
        o_cia.ʽ().putLong("MaxPageId", wiseJointDetailResponse.ˏ());
        o_cia.ʽ().putInt("ReqPageNum", o_eyi.ˊ());
        o_cia.ͺ();
        Logger.ˎ("BuoyDataProviderBuilder", "buildProvider, receive new layoutdata, size: " + ˊ);
    }

    private static int ˊ(cia o_cia, List<LayoutData<CardBean>> list) {
        if (CollectCheck.isEmpty(list)) {
            Logger.e("BuoyDataProviderBuilder", "analyseLayoutDatas, layoutdatas is empty");
            return 0;
        }
        int i = 0;
        for (LayoutData layoutData : list) {
            long ˎ = layoutData.ˎ();
            chz ॱ = o_cia.ॱ(ˎ);
            if (ॱ == null) {
                Logger.e("BuoyDataProviderBuilder", "analyseLayoutDatas, item == null");
            } else if (layoutData.ˋ() == null) {
                Logger.e("BuoyDataProviderBuilder", "analyseLayoutDatas, layoutData.getDataList() == null, layoutId:" + ˎ);
            } else {
                int size = layoutData.ˋ().size();
                int i2 = i + size;
                ListIterator listIterator = layoutData.ˋ().listIterator(size);
                while (listIterator.hasPrevious()) {
                    BaseCardBean baseCardBean = (BaseCardBean) listIterator.previous();
                    if (ॱ.ˎ(baseCardBean.ˋ())) {
                        if (Logger.ˎ()) {
                            Logger.ˏ("BuoyDataProviderBuilder", "analyseLayoutDatas, Node has bean filtered: " + baseCardBean.getClass().getSimpleName());
                        }
                        listIterator.remove();
                    } else {
                        ˏ(listIterator, baseCardBean);
                    }
                }
                ॱ.ˎ(layoutData.ˋ());
                i = i2;
            }
        }
        return i;
    }

    private static void ˏ(ListIterator<CardBean> listIterator, BaseCardBean baseCardBean) {
        if (baseCardBean.ˋ(0)) {
            listIterator.remove();
        }
    }

    private static void ॱ(cia o_cia, List<Layout> list) {
        if (CollectCheck.isEmpty(list)) {
            Logger.e("BuoyDataProviderBuilder", "layouts isEmpty");
            return;
        }
        for (Layout layout : list) {
            long ˋ = layout.ˋ();
            int ॱ = layout.ॱ();
            if (ॱ == -1) {
                Logger.e("BuoyDataProviderBuilder", "analyseLayouts, unsupport card: " + layout);
            } else {
                chz ˋ2 = o_cia.ˋ(ˋ, ॱ, layout.ˊ(), null);
                if (ˋ2 != null) {
                    ˋ2.ˋ(o_cia.csSheet, layout.ˏ());
                } else {
                    Logger.e("BuoyDataProviderBuilder", "analyseLayouts, cardChunk == null");
                }
            }
        }
    }
}
